-- This file is part of the Fantasy Grounds Open Foundation Ruleset project. 
-- For the latest information, see http://www.fantasygrounds.com/
--
-- Copyright 2008 SmiteWorks Ltd.
--
-- This file is provided under the Open Game License version 1.0a
-- Refer to the license.html file for the full license text
--
-- All producers of work derived from this material are advised to
-- familiarize themselves with the license, and to take special
-- care in providing the definition of Product Identity (as specified
-- by the OGL) in their products.
--
-- All material submitted to the Open Foundation Ruleset project must
-- contain this notice in a manner applicable to the source file type.


function onInit()
	statenode = window.getDatabaseNode().createChild(getName(), "string");
	setState(statenode.getValue());
end

function onDrop(x, y, draginfo)
	if draginfo.isType("combattrackerff") then
		local s = draginfo.getStringData();
		setState(s);
	end
end

function onClickDown(button, x, y)
	if button == 2 then
		setState(nil);
	end
end

function setState(s)
	statenode.setValue(s);
	if stateicons[1][s] then
		setIcon(stateicons[1][s][1]);
	else
		setIcon(icon[1]);
	end
end

function getState()
	return statenode.getValue();
end
